﻿//using System;
//using UnityEngine;
//using XUpdater;
//using XUtliPoolLib;

//namespace XMainClient
//{
//	// Token: 0x02000B31 RID: 2865
//	internal class XSirJoystick : XSingleton<XSirJoystick>
//	{
//		// Token: 0x17003013 RID: 12307
//		// (get) Token: 0x0600A7B1 RID: 42929 RVA: 0x001DBAE0 File Offset: 0x001D9CE0
//		private IXGameSirControl SirControl
//		{
//			get
//			{
//				return XSingleton<XUpdater.XUpdater>.singleton.GameSirControl;
//			}
//		}

//		// Token: 0x0600A7B2 RID: 42930 RVA: 0x001DBAFC File Offset: 0x001D9CFC
//		public XSirJoystick()
//		{
//			for (int i = 0; i < XSirJoystick._touch_count_total_frame; i++)
//			{
//				this._touches[i] = new XTouchItem();
//			}
//		}

//		// Token: 0x0600A7B3 RID: 42931 RVA: 0x001DBC0C File Offset: 0x001D9E0C
//		public XTouchItem GetTouch(int touch)
//		{
//			return this._touches[touch];
//		}

//		// Token: 0x17003014 RID: 12308
//		// (get) Token: 0x0600A7B4 RID: 42932 RVA: 0x001DBC28 File Offset: 0x001D9E28
//		public int touchCount
//		{
//			get
//			{
//				return this._touch_count_this_frame;
//			}
//		}

//		// Token: 0x17003015 RID: 12309
//		// (get) Token: 0x0600A7B5 RID: 42933 RVA: 0x001DBC40 File Offset: 0x001D9E40
//		public bool Enabled
//		{
//			get
//			{
//				return this.SirControl != null && this.SirControl.IsConnected();
//			}
//		}

//		// Token: 0x0600A7B6 RID: 42934 RVA: 0x001DBC68 File Offset: 0x001D9E68
//		public void Update()
//		{
//			this._touch_count_this_frame = 0;
//			this.OnTouch();
//			this.UpdateRocker();
//			this.UpdateRotate();
//		}

//		// Token: 0x0600A7B7 RID: 42935 RVA: 0x001DBC88 File Offset: 0x001D9E88
//		private void OnTouch()
//		{
//			bool button = this.SirControl.GetButton(XGameSirKeyCode.BTN_THUMBL);
//			if (button)
//			{
//				XSingleton<XScene>.singleton.GameCamera.BackToPlayer();
//			}
//		}

//		// Token: 0x0600A7B8 RID: 42936 RVA: 0x001DBCBC File Offset: 0x001D9EBC
//		private void UpdateRocker()
//		{
//			float axis = this.SirControl.GetAxis(XGameSirKeyCode.AXIS_X);
//			float num = -this.SirControl.GetAxis(XGameSirKeyCode.AXIS_Y);
//			bool flag = axis != 0f || num != 0f;
//			if (flag)
//			{
//				this._touches[this._touch_count_this_frame].faketouch.fingerId = XFastEnumIntEqualityComparer<XFingerId>.ToInt(XFingerId.XJoystick_1);
//				this._touches[this._touch_count_this_frame].faketouch.deltaTime = Time.smoothDeltaTime;
//				this._touches[this._touch_count_this_frame].faketouch.phase = ((this._x == 0f && this._y == 0f) ? TouchPhase.Began : TouchPhase.Moved);
//				this._touches[this._touch_count_this_frame].faketouch.position = ((this._touches[this._touch_count_this_frame].faketouch.phase == TouchPhase.Began) ? this._RockerPos : ((axis != 0f && num != 0f) ? new Vector2(this._RockerPos.x + axis * XSingleton<XVirtualTab>.singleton.MaxDistance * 0.707f, this._RockerPos.y + num * XSingleton<XVirtualTab>.singleton.MaxDistance * 0.707f) : new Vector2(this._RockerPos.x + axis * XSingleton<XVirtualTab>.singleton.MaxDistance, this._RockerPos.y + num * XSingleton<XVirtualTab>.singleton.MaxDistance)));
//				this._touches[this._touch_count_this_frame].faketouch.tapCount = 1;
//				this._touches[this._touch_count_this_frame].Fake = true;
//				this._touch_count_this_frame++;
//			}
//			else
//			{
//				bool flag2 = this._x != 0f || this._y != 0f;
//				if (flag2)
//				{
//					this._touches[this._touch_count_this_frame].faketouch.fingerId = XFastEnumIntEqualityComparer<XFingerId>.ToInt(XFingerId.XJoystick_1);
//					this._touches[this._touch_count_this_frame].faketouch.position = this._RockerPos;
//					this._touches[this._touch_count_this_frame].faketouch.deltaTime = Time.smoothDeltaTime;
//					this._touches[this._touch_count_this_frame].faketouch.phase = TouchPhase.Ended;
//					this._touches[this._touch_count_this_frame].faketouch.tapCount = 1;
//					this._touches[this._touch_count_this_frame].Fake = true;
//					this._touch_count_this_frame++;
//				}
//			}
//			this._x = axis;
//			this._y = num;
//		}

//		// Token: 0x0600A7B9 RID: 42937 RVA: 0x001DBF68 File Offset: 0x001DA168
//		private void UpdateRotate()
//		{
//			float axis = this.SirControl.GetAxis(XGameSirKeyCode.AXIS_Z);
//			float num = -this.SirControl.GetAxis(XGameSirKeyCode.AXIS_RZ);
//			bool flag = axis != 0f || num != 0f;
//			if (flag)
//			{
//				this._touches[this._touch_count_this_frame].faketouch.fingerId = XFastEnumIntEqualityComparer<XFingerId>.ToInt(XFingerId.XJoystick_0);
//				this._touches[this._touch_count_this_frame].faketouch.deltaTime = Time.smoothDeltaTime;
//				this._touches[this._touch_count_this_frame].faketouch.deltaPosition = new Vector2(axis, num);
//				bool flag2 = this._z == 0f && this._rz == 0f;
//				if (flag2)
//				{
//					this._touches[this._touch_count_this_frame].faketouch.phase = 0;
//					this._touches[this._touch_count_this_frame].faketouch.position = this._RotatePos;
//					this._tempPos = this._RotatePos;
//				}
//				else
//				{
//					bool flag3 = this._touches[this._touch_count_this_frame].faketouch.deltaPosition.sqrMagnitude >= 0.5f;
//					if (flag3)
//					{
//						this._tempPos += this._touches[this._touch_count_this_frame].faketouch.deltaPosition * (float)this._RotateStep;
//						this._tempPos.x = Mathf.Clamp(this._tempPos.x, this._RotateRangeX.x, this._RotateRangeX.y);
//						this._tempPos.y = Mathf.Clamp(this._tempPos.y, this._RotateRangeY.x, this._RotateRangeY.y);
//						this._touches[this._touch_count_this_frame].faketouch.phase = TouchPhase.Moved;
//						this._touches[this._touch_count_this_frame].faketouch.position = this._tempPos;
//					}
//				}
//				this._touches[this._touch_count_this_frame].faketouch.tapCount = 1;
//				this._touches[this._touch_count_this_frame].Fake = true;
//				this._touch_count_this_frame++;
//			}
//			else
//			{
//				bool flag4 = this._z != 0f || this._rz != 0f;
//				if (flag4)
//				{
//					this._touches[this._touch_count_this_frame].faketouch.fingerId = XFastEnumIntEqualityComparer<XFingerId>.ToInt(XFingerId.XJoystick_0);
//					this._touches[this._touch_count_this_frame].faketouch.position = this._tempPos;
//					this._touches[this._touch_count_this_frame].faketouch.deltaTime = Time.smoothDeltaTime;
//					this._touches[this._touch_count_this_frame].faketouch.phase = TouchPhase.Ended;
//					this._touches[this._touch_count_this_frame].faketouch.tapCount = 1;
//					this._touches[this._touch_count_this_frame].Fake = true;
//					this._touch_count_this_frame++;
//				}
//			}
//			this._z = axis;
//			this._rz = num;
//		}

//		// Token: 0x04003E10 RID: 15888
//		private XTouchItem[] _touches = new XTouchItem[XSirJoystick._touch_count_total_frame];

//		// Token: 0x04003E11 RID: 15889
//		private Vector2 _RotatePos = new Vector2((float)Screen.width * 0.75f, (float)Screen.height * 0.5f);

//		// Token: 0x04003E12 RID: 15890
//		private Vector2 _RockerPos = new Vector2((float)Screen.width * 0.2f, (float)Screen.height * 0.25f);

//		// Token: 0x04003E13 RID: 15891
//		private Vector2 _RotateRangeX = new Vector2((float)Screen.width * 0.5f, (float)Screen.width * 1f);

//		// Token: 0x04003E14 RID: 15892
//		private Vector2 _RotateRangeY = new Vector2((float)Screen.height * 0.2f, (float)Screen.height * 0.8f);

//		// Token: 0x04003E15 RID: 15893
//		private int _touch_count_this_frame = 0;

//		// Token: 0x04003E16 RID: 15894
//		private static int _touch_count_total_frame = 2;

//		// Token: 0x04003E17 RID: 15895
//		private float _x = 0f;

//		// Token: 0x04003E18 RID: 15896
//		private float _y = 0f;

//		// Token: 0x04003E19 RID: 15897
//		private float _z = 0f;

//		// Token: 0x04003E1A RID: 15898
//		private float _rz = 0f;

//		// Token: 0x04003E1B RID: 15899
//		private Vector2 _tempPos;

//		// Token: 0x04003E1C RID: 15900
//		private int _RotateStep = 10;
//	}
//}
